<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>目录结构 | vue2-element-dict</title>
    <meta name="generator" content="VuePress 1.9.7">
    <link rel="icon" href="/vue2-element-dict/favicon.ico">
    <script defer="defer" async="async" src="https://cpro.baidustatic.com/cpro/ui/cm.js"></script>
    <meta name="description" content="vue2-element-dict字典包官方使用文档">
    
    <link rel="preload" href="/vue2-element-dict/assets/css/0.styles.4793a278.css" as="style"><link rel="preload" href="/vue2-element-dict/assets/js/app.b15cbcb6.js" as="script"><link rel="preload" href="/vue2-element-dict/assets/js/4.26f72541.js" as="script"><link rel="preload" href="/vue2-element-dict/assets/js/35.a2561dd0.js" as="script"><link rel="prefetch" href="/vue2-element-dict/assets/js/1.de614e96.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/10.2f2bf95a.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/11.ff41966b.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/12.b8277606.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/13.b04a73f4.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/14.4d6242d1.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/15.630dac4e.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/16.a7c1d843.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/17.2b8a9633.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/18.8eb3630c.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/19.6786c2bb.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/2.53443f2d.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/20.a5157105.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/21.d4d5c2c2.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/22.8b3228db.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/23.c5c8d87f.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/24.fccc0622.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/25.01db42e3.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/26.faa5aea5.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/27.80a1c84f.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/28.a9a8221b.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/29.2fcd2f4e.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/30.dd694ba1.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/31.99cbdf15.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/32.1fb6dad3.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/33.7b640408.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/34.1c4b9978.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/36.c02c0325.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/37.f5704977.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/5.0ef459b8.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/6.d8b0c3f6.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/7.08430ef6.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/8.d5c78b56.js"><link rel="prefetch" href="/vue2-element-dict/assets/js/9.cbf8f2c2.js">
    <link rel="stylesheet" href="/vue2-element-dict/assets/css/0.styles.4793a278.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/vue2-element-dict/" class="home-link router-link-active"><!----> <span class="site-name">vue2-element-dict</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/vue2-element-dict/" class="nav-link">
  主页
</a></div><div class="nav-item"><a href="/vue2-element-dict/guide/" class="nav-link router-link-active">
  指南
</a></div><div class="nav-item"><a href="https://www.npmjs.com/package/vue2-element-dict" target="_blank" rel="noopener noreferrer" class="nav-link external">
  npm地址
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/vue2-element-dict/" class="nav-link">
  主页
</a></div><div class="nav-item"><a href="/vue2-element-dict/guide/" class="nav-link router-link-active">
  指南
</a></div><div class="nav-item"><a href="https://www.npmjs.com/package/vue2-element-dict" target="_blank" rel="noopener noreferrer" class="nav-link external">
  npm地址
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>捐赠</span> <!----></p> <!----></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>指南</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/vue2-element-dict/guide/" aria-current="page" class="sidebar-link">介绍</a></li><li><a href="/vue2-element-dict/guide/fast/" class="sidebar-link">快速开始</a></li><li><a href="/vue2-element-dict/guide/directory-structure/" aria-current="page" class="active sidebar-link">目录结构</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/vue2-element-dict/guide/directory-structure/#请求接口配置" class="sidebar-link">请求接口配置</a></li><li class="sidebar-sub-header"><a href="/vue2-element-dict/guide/directory-structure/#固定字典数据配置" class="sidebar-link">固定字典数据配置</a></li><li class="sidebar-sub-header"><a href="/vue2-element-dict/guide/directory-structure/#全局字典配置" class="sidebar-link">全局字典配置</a></li></ul></li><li><a href="/vue2-element-dict/guide/config/" class="sidebar-link">字典包配置</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>普通字典组件</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/vue2-element-dict/components/el-select-dict/" class="sidebar-link">select-dict选择器</a></li><li><a href="/vue2-element-dict/components/el-radio-dict/" class="sidebar-link">radio-dict单选框</a></li><li><a href="/vue2-element-dict/components/el-checkbox-dict/" class="sidebar-link">checkbox-dict多选框</a></li><li><a href="/vue2-element-dict/components/el-radio-button-dict/" class="sidebar-link">radio-button-dict单选框</a></li><li><a href="/vue2-element-dict/components/el-checkbox-button-dict/" class="sidebar-link">checkbox-button-dict多选框</a></li><li><a href="/vue2-element-dict/components/el-tabs-dict/" class="sidebar-link">tabs-dict标签页</a></li><li><a href="/vue2-element-dict/components/el-tag-dict/" class="sidebar-link">tag-dict标签</a></li><li><a href="/vue2-element-dict/components/el-link-dict/" class="sidebar-link">link-dict链接</a></li><li><a href="/vue2-element-dict/components/el-text-dict/" class="sidebar-link">text-dict链接</a></li><li><a href="/vue2-element-dict/components/el-button-dict/" class="sidebar-link">button-dict链接</a></li><li><a href="/vue2-element-dict/components/el-table-colmun-dict/" class="sidebar-link">el-table-colmun-dict表格</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>树形字典组件</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/vue2-element-dict/components/el-cascader-dict/" class="sidebar-link">cascader-dict联级选项</a></li><li><a href="/vue2-element-dict/components/el-tree-dict/" class="sidebar-link">tree-dict树菜单</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>过滤器</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/vue2-element-dict/filters/dict/" class="sidebar-link">字典过滤器</a></li><li><a href="/vue2-element-dict/filters/tree-dict/" class="sidebar-link">树形字典过滤器</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>方法</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/vue2-element-dict/functions/dict/" class="sidebar-link">字典方法</a></li><li><a href="/vue2-element-dict/functions/other/" class="sidebar-link">其他方法</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="目录结构"><a href="#目录结构" class="header-anchor">#</a> 目录结构</h1> <p>好的目录结构能够让项目更加简单易读，本篇文章推荐大家使用如下目录结构，让项目结构更加清晰明了。</p> <p>推荐的目录结构如下：</p> <div class="language- extra-class"><pre class="language-text"><code>.
├── src
    ├── api
    │   ├── modules 
    │   │   ├── common-api.js
    │   ├── axios.js 统一请求，拦截及响应均在此处理
    │	  ├── index.js 对modules的请求进行统一处理
    ├── assets
    │   ├── imgs   项目图片存放目录
    │   ├── data
    │   │   └── dict.js
    ├── components  项目组件存放目录
    ├── directives  全局自定义指令
    ├── router   路由配置
    ├── store    vuex数据处理 
    ├── styles   样式
    ├── utils    公共常用方法目录
    ├── views    页面存放目录
    ├── app.vue  项目主入口页面
    ├── dict-config.js
    └── main.js 项目主入口文件
    
</code></pre></div><blockquote><p><strong>注意</strong></p> <p>请留意目录名的大写，及有无s结尾</p></blockquote> <ul><li><p><code>src/api/modules/common-api.js</code>: 用于存放项目一些公共常用接口请求。</p></li> <li><p><code>src/assets/data/dict.js</code>: 存放项目固定不变字典数据。</p></li> <li><p><code>src/dict-config.js</code>: 字典包配置。</p></li></ul> <p>关于请求的优化，前往微信公众号【爆米花小布】</p> <!----> <h2 id="请求接口配置"><a href="#请求接口配置" class="header-anchor">#</a> 请求接口配置</h2> <p>**注意：以下为模拟接口请求响应数据 src/api/modules/common-api.js **</p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token comment">//获取字典接口 </span>
<span class="token keyword">export</span> <span class="token keyword">function</span> <span class="token function">getDictCodeApi</span><span class="token punctuation">(</span><span class="token parameter">options</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">var</span> promise <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token parameter">resolve</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">const</span> dictCodeList <span class="token operator">=</span> <span class="token punctuation">{</span>
      <span class="token string-property property">&quot;FRUITS&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;1&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;西瓜&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;2&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;草莓&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;3&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;莲雾&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;4&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;荔枝&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;5&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;青梅&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;6&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;芒果&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;7&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;火龙果&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;8&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;山竹&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;9&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;橙子&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;10&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;人参果&quot;</span>
        <span class="token punctuation">}</span>
      <span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;SPORTS&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;1&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;篮球&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;2&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;足球&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;3&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;乒乓球&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;4&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;羽毛球&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;5&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;网球&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;6&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;保龄球&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;7&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;水球&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;8&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;台球&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;9&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;跑步&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;10&quot;</span><span class="token punctuation">,</span>
          <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;游泳&quot;</span>
        <span class="token punctuation">}</span>
      <span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;AAC004&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;1&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;男&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;2&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;女&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;9&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;未说明性别&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;STATUSHIERARCHY&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;5&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Lv5认证&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;4&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Lv4认证&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;3&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;Lv3认证&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;AAC058&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;01&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;居民身份证(户口簿)&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;02&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;中国人民解放军军官证&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;03&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;中国人民武装警察警官证&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;AAC005&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;01&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;汉族&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;02&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;蒙古族&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;20&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;傈傈族&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;LEGAL_STATUS&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;000&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;锁定&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;001&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;正常&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;PERSON_TYPE&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;005&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;民营企业代表&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span><span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;004&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;个体工商户&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;003&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;机关事业单位法人&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;002&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;社团法人&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;001&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;企业法人&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;UNIT_TYPE&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;3&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;地税编号&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;2&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;统一信用代码&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;1&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;组织机构代码&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;MCC_TYPE&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;1&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;农,林,牧,渔业&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;10&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;金融业&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;11&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;房地产业&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;UNIT_STATUS&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;000&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;注销&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;001&quot;</span><span class="token punctuation">,</span>
        <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;正常&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">]</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">let</span> codeData <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span>options<span class="token operator">&amp;&amp;</span>options<span class="token punctuation">.</span>type<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">const</span> typeList <span class="token operator">=</span> options<span class="token punctuation">.</span>type<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">&quot;,&quot;</span><span class="token punctuation">)</span>
      <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">let</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> typeList<span class="token punctuation">.</span>length<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">const</span> type <span class="token operator">=</span> typeList<span class="token punctuation">[</span>i<span class="token punctuation">]</span>
        codeData<span class="token punctuation">[</span>type<span class="token punctuation">]</span> <span class="token operator">=</span> dictCodeList<span class="token punctuation">[</span>type<span class="token punctuation">]</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
      codeData <span class="token operator">=</span> dictCodeList
    <span class="token punctuation">}</span>
    <span class="token keyword">const</span> data <span class="token operator">=</span> <span class="token punctuation">{</span>
      <span class="token string-property property">&quot;code&quot;</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;data&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
        <span class="token literal-property property">dictData</span><span class="token operator">:</span> codeData<span class="token punctuation">,</span>
        <span class="token literal-property property">dictVersion</span><span class="token operator">:</span> <span class="token string">&quot;0.0.2&quot;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span>
      <span class="token literal-property property">message</span><span class="token operator">:</span> <span class="token string">&quot;成功&quot;</span><span class="token punctuation">,</span>
      <span class="token literal-property property">timestamp</span><span class="token operator">:</span> <span class="token string">&quot;1594565635&quot;</span><span class="token punctuation">,</span>
      <span class="token literal-property property">type</span><span class="token operator">:</span> <span class="token string">&quot;info&quot;</span>
    <span class="token punctuation">}</span>
    <span class="token function">resolve</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
  <span class="token keyword">return</span> promise
<span class="token punctuation">}</span>

<span class="token comment">//获取全局配置  包含版本号</span>
<span class="token keyword">export</span> <span class="token keyword">function</span> <span class="token function">getGlobalConfigApi</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">resolve<span class="token punctuation">,</span> reject</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
    <span class="token function">resolve</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token literal-property property">version</span><span class="token operator">:</span> <span class="token string">&quot;0.0.2&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span></code></pre></div><h2 id="固定字典数据配置"><a href="#固定字典数据配置" class="header-anchor">#</a> 固定字典数据配置</h2> <p>**注意：以下为项目固定不变字典数据 src/assets/data/dict.js **</p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
  <span class="token constant">SEX</span><span class="token operator">:</span> <span class="token punctuation">[</span>
    <span class="token punctuation">{</span>
      <span class="token literal-property property">value</span><span class="token operator">:</span> <span class="token string">&quot;1&quot;</span><span class="token punctuation">,</span>
      <span class="token literal-property property">label</span><span class="token operator">:</span> <span class="token string">&quot;男&quot;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">{</span>
      <span class="token literal-property property">value</span><span class="token operator">:</span> <span class="token string">&quot;2&quot;</span><span class="token punctuation">,</span>
      <span class="token literal-property property">label</span><span class="token operator">:</span> <span class="token string">&quot;女&quot;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">{</span>
      <span class="token literal-property property">value</span><span class="token operator">:</span> <span class="token string">&quot;3&quot;</span><span class="token punctuation">,</span>
      <span class="token literal-property property">label</span><span class="token operator">:</span> <span class="token string">&quot;未知&quot;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token literal-property property">niceOrBad</span><span class="token operator">:</span> <span class="token punctuation">[</span>
    <span class="token punctuation">{</span>
      <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;0&quot;</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;好&quot;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
      <span class="token string-property property">&quot;value&quot;</span><span class="token operator">:</span> <span class="token string">&quot;1&quot;</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;差&quot;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token literal-property property">area</span><span class="token operator">:</span> <span class="token punctuation">[</span>
    <span class="token punctuation">{</span>
      <span class="token string-property property">&quot;id&quot;</span><span class="token operator">:</span> <span class="token string">&quot;110000&quot;</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;parentId&quot;</span><span class="token operator">:</span> <span class="token string">&quot;0&quot;</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;北京&quot;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">{</span>
      <span class="token string-property property">&quot;id&quot;</span><span class="token operator">:</span> <span class="token string">&quot;110100&quot;</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;parentId&quot;</span><span class="token operator">:</span> <span class="token string">&quot;0&quot;</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;label&quot;</span><span class="token operator">:</span> <span class="token string">&quot;北京市&quot;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">{</span>
      <span class="token string-property property">&quot;id&quot;</span><span class="token operator">:</span> <span class="token string">&quot;110101&quot;</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;parentId&quot;</span><span class="token operator">:</span> <span class="token string">&quot;110100&quot;</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;areaName&quot;</span><span class="token operator">:</span> <span class="token string">&quot;东城区&quot;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">{</span>
      <span class="token string-property property">&quot;id&quot;</span><span class="token operator">:</span> <span class="token string">&quot;110102&quot;</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;parentId&quot;</span><span class="token operator">:</span> <span class="token string">&quot;110100&quot;</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;areaName&quot;</span><span class="token operator">:</span> <span class="token string">&quot;西城区&quot;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">{</span>
      <span class="token string-property property">&quot;id&quot;</span><span class="token operator">:</span> <span class="token string">&quot;110105&quot;</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;parentId&quot;</span><span class="token operator">:</span> <span class="token string">&quot;110100&quot;</span><span class="token punctuation">,</span>
      <span class="token string-property property">&quot;areaName&quot;</span><span class="token operator">:</span> <span class="token string">&quot;朝阳区&quot;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">]</span>
<span class="token punctuation">}</span></code></pre></div><h2 id="全局字典配置"><a href="#全局字典配置" class="header-anchor">#</a> 全局字典配置</h2> <p>**注意：以下为字典包配置文件 src/dict-config.js   更多配置详细<a href="/vue2-element-dict/guide/config/">字典包配置项&gt;&gt;</a></p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token keyword">import</span> <span class="token punctuation">{</span>getDictCodeApi<span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;@/api/modules/common-api.js&quot;</span>
<span class="token keyword">import</span> localDictCodes <span class="token keyword">from</span> <span class="token string">&quot;@/assets/data/dict.js&quot;</span>
<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
    getDictCodeApi<span class="token punctuation">,</span> <span class="token comment">//必传 获取字典数据接口</span>
    localDictCodes<span class="token punctuation">,</span> <span class="token comment">//选填 项目写死的字典数据</span>
    <span class="token literal-property property">version</span><span class="token operator">:</span> <span class="token string">&quot;0.0.1&quot;</span>
<span class="token punctuation">}</span>
</code></pre></div></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">5/17/2023, 10:19:54 PM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/vue2-element-dict/guide/fast/" class="prev">
        快速开始
      </a></span> <span class="next"><a href="/vue2-element-dict/guide/config/">
        字典包配置
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"><div id="loading-mask"><div class="loading-wrapper"><span class="loading-dot loading-dot-spin"><i></i> <i></i> <i></i> <i></i></span></div></div><!----></div></div>
    <script src="/vue2-element-dict/assets/js/app.b15cbcb6.js" defer></script><script src="/vue2-element-dict/assets/js/4.26f72541.js" defer></script><script src="/vue2-element-dict/assets/js/35.a2561dd0.js" defer></script>
  </body>
</html>
